﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using BCEntity.TMS.Order.OrderAssignRecord;

namespace BCData.TMS.Order.OrderAssignRecord
{
    public interface IOrderAssignRecordData
    {
        /// <summary>
        /// 添加新订单指派纪录
        /// </summary>
        /// <param name="orderAssignRecordEntity">订单指派纪录</param>
        /// <returns></returns>
        Task<OrderAssignRecordEntity> InsertAsync(OrderAssignRecordEntity orderAssignRecordEntity);

        /// <summary>
        /// 修改订单指派记录
        /// </summary>
        /// <param name="orderAssignRecordEntity">订单指派纪录</param>
        /// <returns></returns>
        Task<OrderAssignRecordEntity> UpdateAsync(OrderAssignRecordEntity orderAssignRecordEntity);


        /// <summary>
        /// 删除订单指派记录
        /// </summary>
        /// <param name="orderAssignRecordId">订单指派纪录id</param>
        /// <returns></returns>
        Task<int> DeleteAsync(long orderAssignRecordId);


        /// <summary>
        /// 获取订单指派记录
        /// </summary>
        /// <param name="orderAssignRecordId">订单指派纪录id</param>
        /// <returns></returns>
        Task<OrderAssignRecordEntity> GetByOrderAssignRecordIdAsync(long orderAssignRecordId);

        /// <summary>
        /// 查询订单指派记录
        /// </summary>
        /// <param name="companyId">公司ID</param>
        /// <param name="departmentId">部门ID</param>
        /// <param name="adminId">管理员ID</param>
        /// <param name="pageIndex">分页页码</param>
        /// <param name="pageSize">分页页数</param>
        /// <returns></returns>
        Task<(IEnumerable<OrderAssignRecordEntity>, int)> GetListAsync(int? companyId, int? departmentId, long? adminId, long? orderId, int pageIndex, int pageSize);

        /// <summary>
        /// 获取订单指派记录
        /// </summary>
        /// <param name="adminId">管理员Id</param>
        /// <param name="orderId">订单Id</param>
        /// <returns></returns>
        Task<OrderAssignRecordEntity> GetByOrdeIdAndAdminIdAsync(long orderId, long adminId, bool isAssign);

        /// <summary>
        /// 根据订单ID获取订单指派记录
        /// </summary>
        /// <param name="orderId">订单ID</param>
        /// <returns></returns>
        Task<IEnumerable<OrderAssignRecordEntity>> GetListByOrderIdAsync(long orderId);

        /// <summary>
        /// 根据司机id获取司机指派记录
        /// </summary>
        /// <param name="driverIds">司机id</param>
        /// <returns></returns>
        Task<IEnumerable<OrderAssignRecordEntity>> GetListByDriverIdAsync(List<long> driverIds);

        /// <summary>
        /// 根据指派人Id获取车辆指派记录
        /// </summary>
        /// <param name="adminIds">指派人ID</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <returns></returns>
        Task<IEnumerable<OrderAssignRecordEntity>> GetOrderAssignListByAdminIds(List<long> adminIds, DateTime? startDate, DateTime? endDate);

        /// <summary>
        /// 查询司机最后一次接单记录
        /// </summary>
        /// <param name="driverId">司机ID</param>
        /// <returns></returns>
        Task<OrderAssignRecordEntity> GetLastReceiveRecordByDriverIdAsync(long driverId);

        /// <summary>
        /// 获取司机最后一次指派记录
        /// </summary>
        /// <param name="driverId">司机ID</param>
        /// <returns></returns>
        Task<OrderAssignRecordEntity> GetLastAssignRecordByDriverIdAsync(long driverId);

        /// <summary>
        /// 更新订单指派记录车牌号
        /// </summary>
        /// <param name="driverId">司机ID</param>
        /// <param name="vehicleNo">车牌号</param>
        /// <returns></returns>
        Task<bool> UpdateVehicleNoByDriverIdAsync(long driverId, string vehicleNo);
        /// <summary>
        /// 更新订单为已接单
        /// </summary>
        /// <param name="orderId">订单编号</param>
        /// <returns></returns>
        Task<bool> UpdateOrderReceivedAsync(long orderId);
    }
}